package com.tkjt.pms.modules.repos.thread;

import com.tkjt.pms.impt.vos.UpdateCIndexVo;
import com.tkjt.pms.impt.vos.UpdateGIndexVo;
import com.tkjt.pms.modules.common.service.TkIndexValueAuditService;
import com.tkjt.pms.modules.repos.service.IndexRepoService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;

import java.io.File;
import java.util.List;

public class ImportDataThread implements Runnable{

    private String fileName;

    private File newFile;

    private ImportParams params;

    private String dataType;

    private String indexYearMonth;

    private IndexRepoService indexRepoService;



    public ImportDataThread(String fileName, File newFile,ImportParams params, String dataType,String indexYearMonth, IndexRepoService indexRepoService) {
        this.fileName = fileName;
        this.newFile = newFile;
        this.params = params;
        this.dataType = dataType;
        this.indexYearMonth = indexYearMonth;
        this.indexRepoService = indexRepoService;

    }

    @Override
    public void run() {
        String indexGroup = "";
        if(fileName.contains("一线")){
            indexGroup = "A01A01A01";
            List<UpdateCIndexVo> results = ExcelImportUtil.importExcel(newFile, UpdateCIndexVo.class, params);
            try {
                indexRepoService.processCIndexData(indexGroup,dataType, indexYearMonth, results);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else{
            indexGroup = "A01A01A02";
            List<UpdateGIndexVo> results = ExcelImportUtil.importExcel(newFile, UpdateGIndexVo.class, params);
            try {
                indexRepoService.processGIndexData(indexGroup,dataType, indexYearMonth, results);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}